package kr.saeildamil.androidstudy_second.multimedia;

import kr.saeildamil.androidstudy_second.R;
import android.app.Activity;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.SoundPool;
import android.media.SoundPool.OnLoadCompleteListener;
import android.os.Bundle;
import android.view.View;

public class SoundPoolTest extends Activity {
	SoundPool pool;
	int ddok;
	int stream;;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch33_soundpooltest);
		
		pool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
		
	}
	SoundPool.OnLoadCompleteListener mListener = new OnLoadCompleteListener() {
		
		@Override
		public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
			if(status ==0){
				stream = soundPool.play	(sampleId, 1,1,0,0,1);
			}
			
		}
	};
			
			
			
			
			
			
			
	public void mOnClick(View v){
		MediaPlayer player;
		switch(v.getId()){
		case R.id.play1:
			pool.play(ddok,1,1,0,0,1);
			break;
		case R.id.play2:
			pool.play(ddok,0.5f,0.5f,0,0,1);
			break;
		case R.id.play3:
			pool.play(ddok,1,1,0,2,1);
			break;
		case R.id.play4:
			pool.play(ddok,1,1,0,0,0.5f);
			break;
		case R.id.play5:
			ddok = pool.load(this, R.raw.dingdong,1);
			pool.play(ddok,1,1,0,0,0.5f);
			break;
		case R.id.play6:
			pool.setOnLoadCompleteListener(mListener);
			pool.load(this, R.raw.dingdong,1);
			break;
		case R.id.play7:
			pool.autoPause();
			break;
		case R.id.play8:
			pool.autoResume();
			break;
		}
	}
}
